# content = input()
content="qweebaweqd"
word= "qwe"
# wor =input()
# word_list= list(word)
dict1={}
for c in word:
    if  c not in dict1:
        dict1[c] = 1
    else:
        dict1[c] +=1

print(dict1)


nemb=len(content)
res=0
for i in range(nemb-1):
    for j in range(i+1,nemb):
        temp=content[i:j]
        dict2={}
        for d in temp:
            if d not in dict1:
                break
            elif d not in dict2:
                dict2[d] =1
            else:
                dict2[d] +=1

        if dict1==dict2:
            res+=1

print(res)